var token = selectByKey("like_token");
//点击保存
function save() {
    var save = document.querySelector('.subsave');
    Tap(save,function(){
        var companyName = document.getElementById("nick_name");
        var tel = document.getElementById("tel");
        var email = document.getElementById("email");
        $.ajax({
            url:pathName+"/api/v1/member/update",
            type:"POST",
            headers:{
                "Accept":"application/json",
                "Authorization":"Bearer " + token
            },
            data:{
                "nick_name":companyName.value,
                "email":email.value,
                "user_logo":"",
                "qq":"",
                "company_photo":""
            },
            success:function(){
                window.location.href = "individual.html";
            }
        })
    });
}
//编辑头像模块
//function PreviewImage(imgFile)
//{
//    var filextension=imgFile.value.substring(imgFile.value.lastIndexOf("."),imgFile.value.length);
//    filextension=filextension.toLowerCase();
//    if ((filextension!='.jpg')&&(filextension!='.gif')&&(filextension!='.jpeg')&&(filextension!='.png')&&(filextension!='.bmp'))
//    {
//        alert("对不起，系统仅支持标准格式的照片，请您调整格式后重新上传，谢谢 !");
//        imgFile.focus();
//    }
//    else
//    {
//        var path;
//        if(document.all)//IE
//        {
//            imgFile.select();
//            path = document.selection.createRange().text;
//
//            document.getElementById("imgPreview").innerHTML="";
//            document.getElementById("imgPreview").style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true',sizingMethod='scale',src=\"" + path + "\")";//使用滤镜效果
//        }
//        else//FF
//        {
//            path = imgFile.files[0].getAsDataURL();
//            document.getElementById("imgPreview").innerHTML = "<img id='img1' width='120px' height='100px' src='"+path+"'/>";
//            // document.getElementById("img1").src = path;
//        }
//    }
//}
window.onload = function(){
   var companyName = document.getElementById("nick_name");
   var tel = document.getElementById("tel");
   var addr = document.getElementById("company_addr");
   var subSave = document.querySelector("subSave");
   var img = document.querySelector("#img");
    //请求个人信息
    $.ajax({
        url:pathName+"/api/v1/member",
        type:"get",
        dataType:"json",
        headers:{
            "Accept":"application/json",
            "Authorization":"Bearer " + token
        },
        success:function(data){
            //console.log(data);
            var mask = document.querySelector(".mask");
            mask.style.display = "none";
            companyName.value = data.member.company_name || "";
            tel.value = data.member.phone || "";
            addr.value = data.member.company_address || "";
            img.src = data.member.company_photo || "";
        }
    })
    //save();
}
